A database is a collection of logically related data arranged in a predetermined format, such as in tables that contain rows and columns. To access the content of a table in the database, queries according to a standard database query language are submitted to the database system. Queries can be issued to insert new entries into a table of a database (such as to insert a row into the table), modify the content of the table, and delete entries from the table.
Database systems often have to store relatively large amounts of data. In certain applications, such as data warehousing applications, some tables store millions of rows of data. A table typically has several columns, with each column associated with a particular data type. Examples of data types include integers, decimals, characters, and so forth. The data type defined for a given column may be allocated a certain amount of storage based on the user definition of the data type. For example, an integer of a column may be defined as a 10-byte integer. As rows are stored into the table, 10 bytes are allocated to the field corresponding to the 10-byte integer column.
In performing a transaction, a database system projects selected rows and columns of one or more base tables into an intermediate or result table. A transaction may involve application of a predicate or some other condition that limits the range of data values that are selected for output to the intermediate or result table. In one example, a base table has a column according to an integer data type that is defined as being 10 bytes long. A transaction may specify a predicate that selects values of the column less than 100. In this case, the selected output values of the column to be inserted into the result table are those values of the integer that are less than 100. A 10-byte integer allocated to store this column is excessive, since the maximum value of the column in the result table is 99. In the result table, a one-byte integer field is sufficient to store values of the column.
In conventional database systems, the data type of a selected column that is projected to an intermediate or result table inherits the data type of the base table. In the above example, the inheritance of a 10-byte integer for storing the column values in the result table leads to inefficient use of storage resources in a database system.